import { UserConfigExport } from 'vite';
import vue from '@vitejs/plugin-vue';
import vueJsx from '@vitejs/plugin-vue-jsx';
// import Icons from 'unplugin-icons/vite';
// import { createSvgIconsPlugin } from 'vite-plugin-svg-icons';
import AutoImport from 'unplugin-auto-import/vite';
import Components from 'unplugin-vue-components/vite';
import { NaiveUiResolver } from 'unplugin-vue-components/resolvers';
// @ts-ignore
// import { removeEmptyFiles } from './removeEmptyFilesPlugin.ts';
import { lazyImport, VxeResolver } from 'vite-plugin-lazy-import';
// import { VxeResolver as unpluginVxeResolver } from '@vxecli/import-unplugin-vue-components';
// import { createStyleImportPlugin } from 'vite-plugin-style-import';
// import VxeTableResolve from '@vxecli/import-vite-plugin-style-import';
// import path from 'path';
export function setupCommonPlugins(configEnv: UserConfigExport) {
	return [
		vue(),
		vueJsx(),
		lazyImport({
			resolvers : [
				VxeResolver({
					libraryName : 'vxe-pc-ui',
					importStyle : false,
					esm         : true
				}),
				VxeResolver({
					libraryName : 'vxe-table',
					importStyle : false,
					esm         : true
				})
			]
		}),
		AutoImport({
			imports : [
				'vue',
				{
					'naive-ui' : [
						/*'useDialog',*/
						'useMessage',
						'useNotification',
						/*'useLoadingBar'*/
					]
				}
			]
		}),
		Components({
			resolvers            : [
				NaiveUiResolver()
			],
			directoryAsNamespace : true
		})
		/*removeEmptyFiles()*/
		/*Icons({
		 autoInstall : true
		 })*/
		// 下列的插件严重影响打包性能,不要使用!
		// 从本身几十秒的打包速度变成了200-300秒
		/*createSvgIconsPlugin({
		 // 指定需要缓存的图标文件夹
		 iconDirs : [
		 path.resolve(process.cwd(), 'src/assets/icons/svg'),
		 path.resolve(process.cwd(), 'node_modules/@sicons/ionicons5')
		 ],
		 // 指定symbolId格式
		 symbolId : 'icon-[name]'
		 })*/
	];
}